/*
 *
 * @User: winter
 * @Date: 2019/10/10
 * @Time: 9:54 上午
 *
 */


var _DDNS = 'bioplatform';
var _ENV = '';

$(document).ready(function () {
    new Swiper(".applications_swiper .applications_swiper_in_container", {
        slidesPerView: 3,
        slidesPerGroup: 3,
        loop: true,
        loopFillGroupWithBlank: true,
        pagination: {
            el: '.swiper-pagination',
            clickable: true,
        },
    });
    window.COLLECT(_DDNS + '-init'); //初始化
});

function more_consultation(text) {
    $("#white_book .modals").show(300);
    _ENV = text;
    window.COLLECT(_DDNS + '-' + text); //初始化
}


// 速石生物云平台优势
$(".advantage_box .advantage .item").click(function () {
    $(this).addClass("active").siblings().removeClass("active");
});

// 用户群体
$(".host_service_box .host_service .right .items .item").click(function () {
    $(this).addClass("active").siblings().removeClass("active");
    var id = $(this).data('id');
    $('.host_service_box .host_service .left').css("background-image", "url(../img/bioplatform/pic-" + id + "@3x.png)");
});


function closeAll() {
    $("#white_book .modals").hide(100);
    $("#app_modals .modals").hide(100);
    $("#submit_modals .modals").hide(100);
    $("#white_book .modals input[name='phone']").val("");
};

var _phone_reg = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/;

function white_book_submit() {
    var name$ = $("#white_book .modals input[name='name']").val();
    var phone$ = $("#white_book .modals input[name='phone']").val();
    if (!name$) {
        alert('称呼不能为空');
        return;
    }
    if (!_phone_reg.test(phone$)) {
        alert('手机号有误，请重填');
        return;
    }
    submitData({
        name: name$,
        mobile: phone$,
        company: '',
        env: _DDNS + '-' + _ENV,
        email: '',
        position: '',
        resource: '',
    }, "我们将在1-3个工作日内与您联系！");
};

function submitData(data, text) {

    $.ajax({
        url: '//webapi.fastonetech.com/api/reservation/web',
        type: 'post',
        contentType: "application/json",
        data: JSON.stringify(data),
        dataType: "json",
        success: function (res) {
            showSubmit(text);
        },
    });
};

// 打开提示框
function showSubmit(text) {
    $("#submit_modals .modal-middle .msg").text(text);
    $("#submit_modals .modals").show(300);
}
